﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using log4net;


namespace VT.Dialogs
{
	class VTDialog
	{
		public static void ShowException(string caption, Exception ex, ILog log = null)
		{
			if (log != null)
			{
				log.Error(string.Format("Exception: '{0}'", caption));
				if (ex == null)
				{
					log.Error("    Message: exception is null ?");
				}
				else
				{
					log.Error(string.Format("    Message:'{0}'", ex.Message));
					if (ex.InnerException != null)
					{
						log.Error(string.Format("    inner exception:{0}", ex.InnerException.Message));
					}
					log.Error(string.Format("    Stack trace:'{0}'", ex.StackTrace));
				}
			}

			MessageBox.Show((ex == null) ? "?": ex.Message, caption, MessageBoxButton.OK, MessageBoxImage.Error);
		}

	}
}
